#include<bits/stdc++.h>
using namespace std;
int n;
queue <int> a[200005];
int l=-1;
int nx[200005];
int cnt=0;
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x!=l)a[++cnt].push(i),l=x;
		else a[cnt].push(i);
		
	}
	for(int i=0;i<n;)
	{
		for(int j=1;j<=cnt;j++)
		{
			//cout<<j<<" :"; 
			if(a[j].size()==1&&a[j].front()!=-1)
			{
				printf("%d ",a[j].front());i++;a[j].pop();
				a[j-1].push(-1);//cout<<"now"<<a[j-1].size();
				nx[j-1]=1;
			}else{
				if(a[j].front()==-1||nx[j-1])
				{//cout<<j<<"=-1"<<endl;
					while(a[j].front()==-1||a[j].empty())j++;
					//cout<<j<<"r"<<endl;
				}
				
				printf("%d ",a[j].front());i++;a[j].pop();
			}
		}
		printf("\n");
		//cout<<i<<":"; 
	}
 } 
 /*
20
1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 0 0
*/
